from rest_framework.serializers import ModelSerializer
from TestInterface.models import TestInterfaceModel, TestInterfaceCaseModel


class TestInterfaceSerializer(ModelSerializer):
    class Meta:
        model = TestInterfaceModel
        fields = "__all__"


class TestInterfaceCaseSerializer(ModelSerializer):
    class Meta:
        model = TestInterfaceCaseModel
        fields = "__all__"


class TestInterfaceCaseListSerializer(ModelSerializer):
    class Meta:
        model = TestInterfaceCaseModel
        fields = ['id', 'title']


class TestInterfaceCaseGetSerializer(ModelSerializer):
    interface = TestInterfaceSerializer()

    class Meta:
        model = TestInterfaceCaseModel
        fields = "__all__"


class TestInterfaceCSerializer(ModelSerializer):
    cases = TestInterfaceCaseListSerializer(many=True,read_only=True,source="testinterfacecasemodel_set")

    class Meta:
        model = TestInterfaceModel
        fields = "__all__"
